#include "pthreadque.h"
int enqueue(queue_t *queue,int data)
{
    node_t *pnew = (node_t*)calloc(1,sizeof(node_t));
    pnew->data = data;
    if(queue->qsize==0)
    {
        queue->head = pnew;
        queue->rear = pnew;
    }
    else
    {
        queue->rear->next = pnew;
        queue->rear = pnew;
    }
    queue->qsize++;
    return 0;
}
int dequeue(queue_t *queue)
{
    node_t *curr = queue->head;
    queue->head = curr->next;
    if(queue->qsize==1)
    {
        queue->rear = NULL;
    }
    int val = curr->data;
    free(curr);
    queue->qsize--;
    return val;
}
int print(queue_t queue)
{
    node_t *curr = queue.head;
    while(curr)
    {
        if(curr->next)
        {
            printf("%3d->",curr->data);
        }
        else
        {
            printf("%3d",curr->data);
        }
        curr = curr->next;
    }
    printf("\n");
    return 0;
}
